package com.focusit.plurarization;

import java.util.HashMap;

/**
 * Main class to get word's plural form.
 * 
 * @author doki
 * 
 */
public class Pluralize {
    // Languadge pluralization rules
    private PluralizationRules rules;

    // Dictionary of word in generic form and it's plural forms
    HashMap<String, WordForm> wordForms = new HashMap<String, WordForm>();

    private WordForm getWordForm(String word) {
        return wordForms.get(word);
    }

    private PluralizationRules getRules() {
        return rules;
    }

    public void setRules(PluralizationRules rules) {
        this.rules = rules;
    }

    public void setWordForms(HashMap<String, WordForm> forms) {
        this.wordForms = forms;
    }

    public void addWordForm(String word, WordForm form) {
        wordForms.put(word, form);
    }

    /**
     * Get plural form based on dictionary
     * 
     * @param n
     * @param word
     * @return
     */
    public final String getString(int n, String word) {
        return getWordForm(word).getWordInForm(getRules().getPluralForm(n));
    }

    /**
     * Get plural form by it's own plural forms
     * 
     * @param n
     * @param form
     * @return
     */
    public final String getString(int n, WordForm form) {
        return form.getWordInForm(getRules().getPluralForm(n));
    }
}
